package cn.kimming.rpc.autoconfigure;

import cn.kimming.rpc.autoconfigure.listener.MyRpcServerApplicationListener;
import cn.kimming.rpc.remoting.spring.ReferenceBeanPostProcessor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties(MyRpcProperties.class)
public class MyRpcAutoConfiguration {
    private static final Logger logger = LoggerFactory.getLogger(MyRpcAutoConfiguration.class);

    @Bean
    public static ReferenceBeanPostProcessor referenceBeanPostProcessor() {
        return new ReferenceBeanPostProcessor();
    }

    @Bean
    @ConditionalOnProperty(value = "my.rpc.server.enabled", havingValue = "true")
    public MyRpcServerApplicationListener myRpcServerApplicationListener() {
        return new MyRpcServerApplicationListener();
    }

}
